#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["NuGet.Config", "."]
COPY ["src/My.ExcelToData.Web/My.ExcelToData.Web.csproj", "src/My.ExcelToData.Web/"]
COPY ["Infrastructure/Infrastructure.csproj", "Infrastructure/"]
COPY ["src/My.ExcelToData.Application/My.ExcelToData.Application.csproj", "src/My.ExcelToData.Application/"]
COPY ["src/My.ExcelToData.Domain/My.ExcelToData.Domain.csproj", "src/My.ExcelToData.Domain/"]
COPY ["src/My.ExcelToData.Domain.Shared/My.ExcelToData.Domain.Shared.csproj", "src/My.ExcelToData.Domain.Shared/"]
COPY ["src/My.ExcelToData.Application.Contracts/My.ExcelToData.Application.Contracts.csproj", "src/My.ExcelToData.Application.Contracts/"]
COPY ["src/My.ExcelToData.HttpApi/My.ExcelToData.HttpApi.csproj", "src/My.ExcelToData.HttpApi/"]
COPY ["src/My.ExcelToData.EntityFrameworkCore/My.ExcelToData.EntityFrameworkCore.csproj", "src/My.ExcelToData.EntityFrameworkCore/"]
RUN dotnet restore "./src/My.ExcelToData.Web/My.ExcelToData.Web.csproj"
COPY . .
WORKDIR "/src/src/My.ExcelToData.Web"
RUN dotnet build "./My.ExcelToData.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./My.ExcelToData.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "My.ExcelToData.Web.dll"]